ArticleDirectory
Preface
Introduction
Install
TDD
Core
Introduction to rspec story
Preface
To understand rspec, we need to first understand what is behaviour driven development (BDD), and BDD is an acceptance test driven planning ), domain driven design and agile development model of test driven development (TDD. Rspec provides TDD su
Rspec-rails Installing dependent libraries
> VI gemfile:
Gem ' Rspec-rails '
The wording of the specification:
Group:d evelopment,: Test do
...
Gem ' rspec-rails ' ...
End
> bundler Install:
Using Rspec-support 3.5.0
using Rspec-core 3.5.1 using
This is a concise rspec guide written by David chelimsky. The original Article is here.
Introduction
To understand rspec, we need to first understand what is behaviour driven development (BDD), and BDD is an acceptance test driven planning ), domain driven design and agile development model of test driven development (TDD. Rspec provides TDD support for BDD dev
If you test the RESTful service by hand, it will be very tedious. Of course, there are some browser plug-ins that can help you manually test by using a visual interface, such as postman, rest console, but every time a system version is updated, you need to perform a lot of tests manually, which is obviously not very practical. Ruby has a lot of excellent gem packages, and you can use them to do the boring work. One of the restclient is one I like better. The
It would be a tedious task if you were to test restful services by hand. Of course, there are some browser plugins that can help you with manual testing through a visual interface, such as postman, rest console, but every time the system version is updated, you need to perform a lot of manual testing, which is obviously not very practical. Ruby has a lot of great gem packs that you can use to do this boring work. Restclient is one of my favorite. The RSPEC
Use rspec for behavior-driven testing:
Require 'machine'Describe machine do # machine is the name of the class to be testedBefore: each do@ Machine = machine. New ([: shopping,: checking_out])@ Machine. Events = {: checkout = >{: from =>: shopping,: To =>: checking_out }}EndIt "shoshould initially have a State of the first State" do@ Machine. state. shocould =: ShoppingEndIt "shoshould remember a list of valid states" do@ Machine. States. shold = [: s
Transfer from Http://lmws.net/describe-vs-context-in-rspecLearn RSpec, not quite understand describe and context. Google a bit, find this article, feel that there is some truth1 in the RSpec world, we often see people using Descirbe code blocks and context code blocks such as1 " launch the Rocket " Do 2 " all ready " Do 3 End 4 5 " not ready " Do 6 End7 EndSo what's the difference between cont
Test Your app's interactions with non-human users, covering external API7.1request Test vs feature Testthe RSpec , this is specifically aimed at API test is best placed in the spec/requests in the catalog, separate from the functional tests written earlier. This test is also not used Capy-bara , because it simulates browser interaction, not program interaction. We're going to use a response from the previous test controller. HTTP verb: Get , Post , De
block for deferred execution, and the detected value is executed two times before and after the request is executed to verify the change (3) Test patch request (UPDATE): The parameter is divided into legal and illegal cases, respectively verify whether the return data, and whether the success of the modification, as well as the rendering template; (4) Test delete request (destroy): Change (Class,: Count). by ( -1), redirect_to (5) Test non-crud action: There is a return value to verify the retu
If cocould not find table appears when running rspec, you need rake DB: Test: Prepare.
If your database uses sqlite3, the database used during the test is not development. sqlite3, but test. sqlite3, depending on the execution process:
Rake DB: Test: Prepare -- Trace** Invoke DB: Test: Prepare (first_time)** Invoke DB: abort_if_pending_migrations (first_time)** Invoke environment (first_time)** Execute Environment** Invoke DB: load_config (first_tim
(1) When it is necessary to re-use the test situation, you can use the Shared_examples ("describe") do end, where needed to use the It_behaves_like "describe" reuse, code written in Controller_ In the Spec.rb file(2) A large number of reusable code
Tutorial on efficient unit tests on Ruby on Rails, rubyrails
In the system developed by the author, a large amount of data needs to be analyzed, which not only requires accurate data analysis, but also requires a certain speed. Before writing the test code, I used several major methods to achieve this requirement. As you can imagine, the code is complex, difficult to maintain, and difficult to expand. Taking the opportunity of business adjustment, I d
When you read the 3rd chapter, the first time you run RSpec in the tutorial fails:
E:\05 Create\code\temp\railstutorial\sample_app>rspec Spec/requests/static_pages_spec.rbE:/05 create/code/temp/railstutorial/sample_app/spec/spec_helper.rb:32:in ' block(2 levels) in From D:/app/coder/railsinstaller/ruby2.1.0/lib/ruby/gems/2.1.0/gems/
Preach Wisdom Blog Video tutorial Download summary |java video tutorial |net video tutorial |php video tutorial | Web video Tutorial
Preach Wisdom Blog Video tutorial Download summary |java video
: Seemingly write test code is time-consuming, in fact, in testing, deployment and subsequent extensions, the test code will save more time.
Environment construction
The author adopts the test environment is more popular general framework: RSpec + Factory Girl, and autotest automatic tool. RSpec is a descriptive language, which is easy to understand by describing system behavior in a workable example.
Link to the PHP object-oriented programming getting started tutorial, and the OOP Getting Started Tutorial. Link to the PHP object-oriented programming getting started tutorial, the OOP Getting Started Tutorial PHP official learning oop: php. netmanuzhoop5.intro. php the following link Source: blog.snsgou.compost-41.ht
Destoon Introductory Tutorial example, Destoon Getting Started tutorial
Release time: 2014-06-23 Editor: www.jbxue.comCollect some Destoon introductory tutorials, Destoon examples, suitable for beginners to learn destoon basic tutorials and tips for getting started. Destoon Introductory Tutorials and tips examples
are Destoon basic tutorials, DESTOON®B2B website Management system is a set of Php+mysql-bas
Introduction to Public Platform development tutorial (graphic), Public introductory tutorial
Key word: Getting Started with public platform development
Author: C + + Lab
Background: The development of public platform requires a certain basic knowledge of PHP, PHP is an embedded HTML language, widely used in web development. There are two ways to transfer data between the server and the developer's server
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.